package com.lzy.product.service.impl;

import com.lzy.framework.core.utils.DozerUtils;
import com.lzy.product.dao.AgentProtocolYieldRatioMapperExt;
import com.lzy.product.dtos.agent.AgentProtocolYieldRatioDto;
import com.lzy.product.entity.AgentProtocolYieldRatio;
import com.lzy.product.service.AgentProtocolYieldRatioService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class AgentProtocolYieldRatioServiceImpl implements AgentProtocolYieldRatioService {

    @Autowired
    private AgentProtocolYieldRatioMapperExt agentProtocolYieldRatioMapperExt;

    @Override
    public Long insert(AgentProtocolYieldRatioDto dto) {
        AgentProtocolYieldRatio agentProtocolYieldRatio = DozerUtils.map(dto, AgentProtocolYieldRatio.class);
        return agentProtocolYieldRatioMapperExt.insertSelective(agentProtocolYieldRatio) > 0 ? agentProtocolYieldRatio.getId() : 0;
    }

    @Override
    public Boolean update(AgentProtocolYieldRatioDto dto) {
        return agentProtocolYieldRatioMapperExt.updateByPrimaryKeySelective(DozerUtils.map(dto, AgentProtocolYieldRatio.class)) > 0;
    }

    @Override
    public Boolean delete(Long id) {
        return null;
    }

    @Override
    public Boolean remove(Long id) {
        return null;
    }

    @Override
    public AgentProtocolYieldRatioDto findById(Long id) {
        return DozerUtils.map(agentProtocolYieldRatioMapperExt.selectByPrimaryKey(id), AgentProtocolYieldRatioDto.class);
    }

    @Override
    public List<AgentProtocolYieldRatioDto> query(AgentProtocolYieldRatioDto dto) {
        return null;
    }

    @Override
    public List<AgentProtocolYieldRatioDto> selectByProtocolId(Long protocolId) {
        return agentProtocolYieldRatioMapperExt.selectByProtocolId(protocolId);
    }

    @Override
    public Boolean deleteByProtocolId(Long protocolId) {
        return agentProtocolYieldRatioMapperExt.deleteByProtocolId(protocolId);
    }
}
